﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace Web.controls
{
    public partial class login : System.Web.UI.UserControl
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void Button1_Click(object sender, EventArgs e)
        {
            string username = TextBox1.Text.Trim().ToString();
            string paw = TextBox2.Text.Trim().ToString();
           // Session["ValidateNum"]
            study.BLL.tb_user ubll = new study.BLL.tb_user();
            study.Model.tb_user umod = new study.Model.tb_user();

            umod = ubll.GetModel(username);
            if (Session["ValidateNum"].ToString().ToLower() == TextBox3.Text.ToLower())
            {
                if (umod != null && umod.username.ToString() == username && umod.pwd.ToString() == paw)
                {
                    Session["USER"] = umod;
                   // Response.Write("<script LANGUAGE='javascript'>alert('登录成功！')</script>");
                }
                else
                {
                    Response.Write("<script LANGUAGE='javascript'>alert('账号或密码错误！')</script>");
                }
            }
            else
            {
                Response.Write("<script LANGUAGE='javascript'>alert('验证码错误！')</script>");
                
            }
        }

        protected void Button2_Click(object sender, EventArgs e)
        {
            Response.Redirect("~/register.aspx");
        }
    }
}